package org.example.struct.array;

/**
 * @author liyishan
 * @date 2024/8/7 10:53
 * @apiNote
 */

public class Test00657JudgeCircle {
    public boolean judgeCircle(String moves) {
        int x = 0, y = 0;
        for (int i = 0; i < moves.length(); i++) {
            if (moves.charAt(i) == 'U') {
                y++;
            } else if (moves.charAt(i) == 'D') {
                y--;
            } else if (moves.charAt(i) == 'L') {
                x--;
            } else if (moves.charAt(i) == 'R') {
                x++;
            }
        }
        if(x==0 && y == 0){
            return true;
        }
        return false;
    }
}
